{template '_header'}
<div class='page-heading'><h2> <i class="fa fa-circle-o"></i>满额立减设置</h2></div>
 
    <form id="dataform"    {ifp 'sale.enough'}action="" method="post"{/if} class="form-horizontal form-validate">
      
       
                     <div class="form-group">
                  
                       <div class="col-sm-12">
                           {ifp 'sale.enough'}
                          <div class='input-group'>
                                   <span class="input-group-addon">单笔订单满</span>
                                   <input type="text" name="data[enoughmoney]"  value="{$data['enoughmoney']}" class="form-control" />
                                   <span class='input-group-addon'>元 立减</span>
                                   <input type="text" name="data[enoughdeduct]"  value="{$data['enoughdeduct']}" class="form-control" />
                                   <span class='input-group-addon'>元</span>
			     <div class="input-group-btn"><button type='button' class="btn btn-default" ><i class="fa fa-minus"></i></button></div>
                           </div>
                           {else}
                           <div class='form-control-static'>{if empty($data['enoughmoney'])}全场包邮{else}订单金额满{$data['enoughmoney']}元包邮{/if}</div>
                           {/if}
                       </div>
                   </div> 
				<div class="form-group">
       
                 <div class="col-sm-12">
						<div class='recharge-items'>
							
							 {loop $data['enoughs'] $item}
						 
						<div class="input-group recharge-item" style="margin-top:5px"> 
							<span class="input-group-addon">单笔订单满</span>
							<input type="text" class="form-control" name='enough[]' value='{$item['enough']}' />
							<span class="input-group-addon">元 立减</span>
							<input type="text" class="form-control"  name='give[]' value='{$item['give']}' />
							<span class="input-group-addon">元</span>
							<div class='input-group-btn'>
							<button class='btn btn-danger' type='button' onclick="removeConsumeItem(this)"><i class='fa fa-remove'></i></button>
							</div>
							 
						</div>
						 {/loop}
						 </div>  
						 
					   <div style="margin-top:5px"> 
					   <button type='button' class="btn btn-default" onclick='addConsumeItem()' style="margin-bottom:5px"><i class='fa fa-plus'></i> 增加优惠项</button>
					   </div>
						<span class="help-block">两项都填写才能生效</span>
						
						
						 
					 
                       </div>
                   </div>  
              
                   {ifp 'sale.enough'}
                <div class="form-group"></div>
                   <div class="form-group">
                    
                           <div class="col-sm-9 col-xs-12">
                                 <input type="submit"  value="保存设置" class="btn btn-primary"/>
                                 
                           </div>
                    </div>
                {/if}
 
     
    </form>
 
<script language='javascript'>
  
                $(function () {
                    $(":checkbox[name='data[enoughfree]']").click(function () {
                        if ($(this).prop('checked')) {
                            $("#enoughfree").show();
                        }
                        else {
                            $("#enoughfree").hide();
                        }
                    })
                   

                })
         
            
	function addConsumeItem(){
		var html= '<div class="input-group recharge-item"  style="margin-top:5px">';
           html+='<span class="input-group-addon">单笔订单满</span>';
		 html+='<input type="text" class="form-control" name="enough[]"  />';
							html+='<span class="input-group-addon">元 立减</span>';
							html+='<input type="text" class="form-control"  name="give[]"  />';
							html+='<span class="input-group-addon">元</span>';
							html+='<div class="input-group-btn"><button class="btn btn-danger" onclick="removeRechargeItem(this)"><i class="fa fa-remove"></i></button></div>';
						html+='</div>';
						$('.recharge-items').append(html);
	}
	function removeConsumeItem(obj){
		$(obj).closest('.recharge-item').remove();
	}
	</script>
{template 'shop/selectareas'}
{template '_footer'}
